# @Time    :2025/3/27 16:28
# print(" ---------遍历 对 k,v同时遍历--方式2--------   ")
my_dict = {
    "Alice": {
        "Math": 85,
        "English": 90,
        "Science": 78
    },
    "Bob": {
        "Math": 92,
        "English": 88,
        "Science": 95
    },
    "Charlie": {
        "Math": 70,
        "English": 75,
        "Science": 80
    }
}
"""
想法：1，for循环对k、v同时遍历取出k的值，适合嵌套字典使用？
本题做题思路总结：
1，先

"""
#my_dict = {'Time': '12', 'Tom': 17}
def cl(my_dict):
    aver = {}
    for k, v in my_dict.items():
        pj_scores = sum(v.values()) / len(v)
        aver[k] = round(pj_scores, 2)
    return aver


result = cl(my_dict)
print(result)






# def cl():
#     averages = {}
#     for k, v in my_dict.items():
#         average_score = sum(v.values()) / len(v)
#         averages[k] = round(average_score, 2)  # 保留两位小数
#     print()
#




# #item = my_dict.items()
# for k,v in my_dict.items():
#         # s=sum(v.values())
#         # print(s)
#     a = sum(v.values()) / len(v)
#     my_dict[k] = round(a, 2)  # 保留两位小数
#     print()
#     #     average_score = sum(v.values()) / len(v)
# #     averages[student] = round(average_score, 2)  # 保留两位小数
# # return averages
#
#
# # # 调用函数并打印结果
# # result = ca_scores(students)
# # print(result)
